package com.zhongyewx.teachercert.ui.fragment;

import android.text.TextUtils;

import com.zhongyewx.teachercert.R;
import com.zhongyewx.teachercert.base.ZYBaseFragment;
import com.zhongyewx.teachercert.mvp.contract.ZYHomeFragContact;
import com.zhongyewx.teachercert.mvp.presenter.ZYHomeFragPresenter;
import com.zhongyewx.teachercert.utils.ZYToastUtil;

public class ZYHomeFragment extends ZYBaseFragment implements ZYHomeFragContact.IHomeFragView  {

    private ZYHomeFragPresenter presenter;
    @Override
    public int getLayoutId() {
        return R.layout.fragment_home_layout;
    }

    @Override
    public void initView() {
        ptrFrameLayout = mRootView.findViewById(R.id.refresh_layout);
        presenter = new ZYHomeFragPresenter();
        if (presenter != null) {
            presenter.attachView(this);
            getLifecycle().addObserver(presenter);
        }
    }

    @Override
    public void initData() {

    }

    @Override
    public void lazyLoad() {
        presenter.getHomeData();
    }
    @Override
    public void showLoading() {

    }

    @Override
    public void dismissLoading() {
        if (ptrFrameLayout.isRefreshing()){
            ptrFrameLayout.refreshComplete();
        }
    }

    @Override
    public void showMsg(String msg) {
        if (!TextUtils.isEmpty(msg)) {
            ZYToastUtil.showCenterToast(getActivity(), msg);
        }
    }

}
